package com.ymttest.business.service;


import com.google.gson.JsonObject;
import com.shop2cn.iapi.agentproducts.parameter.*;
import com.shop2cn.iapi.agentproducts.parameter.rebate.ConditionRebateValueDto;
import com.shop2cn.iapi.agentproducts.parameter.rebate.ProductRebateDto;
import com.shop2cn.iapi.agentproducts.service.*;
import com.ymatou.iapi.godmch.parameter.AgentTypeVo;
import com.ymatou.iapi.godmch.parameter.listagentTypeBean;
import com.ymatou.iapi.prodstock.parameter.AgentProductPo;
import com.ymt.core.tool.Logger;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.business.service.shenqi.bean.ShenqiUserSet;
import com.ymttest.database.annotation.SqlMapperFactory;
import com.ymttest.database.annotation.product.IntergratedProductMapper;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.model.YmtProductsI;
import com.ymttest.database.model.mch_relation;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
import com.ymttest.database.sqlwapper.godmch.mch_relationWapper;
import com.ymttest.utils.TestDataManager;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.http.client.ClientProtocolException;

//微信代理商品
public class AddAgentProductCallService {
	public static Integer BrandId=21488;
	public static Integer BrandId2=10253;
	
	public static Integer CategoryId1=1001;
	public static Integer CategoryId2=1002;
	public static Integer CategoryId3=1003;
	public static Integer CategoryId3_2=1004;
    private static IntergratedProductMapper ipm = SqlMapperFactory
            .getIntergratedProductMapper();
    
    
    
    /**
     * 一键导入
     * @param agentUserId
     * @param ParentProductId
     * @throws IOException 
     * @throws ClientProtocolException 
     */
    public static String AutoImportProduct(Integer agentUserId,String ParentProductId) throws ClientProtocolException, IOException{
		AutoImportProductBean autoimportproductBean = new AutoImportProductBean();
		AutoImportProductCall autoimportproductCall = new AutoImportProductCall();
    	autoimportproductBean.setUserId(agentUserId);
		autoimportproductBean.setParentProductId(ParentProductId);
		autoimportproductCall.setData(autoimportproductBean);
		autoimportproductCall.callService();
		return autoimportproductCall.getString("productId");
    }
    /**
     * 设置商品是否露出
     * @param userId
     * @param ProductIds
     * @param visible
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static void SetVisible(Integer userId,List<String> ProductIds,boolean visible) throws ClientProtocolException, IOException{
    	SetVisibleBean setvisibleBean = new SetVisibleBean();
		SetVisibleCall setvisibleCall = new SetVisibleCall();
    	setvisibleBean.setProductIds(ProductIds);
		setvisibleBean.setUserId(userId);
		setvisibleBean.setVisible(visible);
		setvisibleCall.setData(setvisibleBean);
		setvisibleCall.callService();			
		Logger.verifyEquals("200", setvisibleCall.getString("code"), "验证code");
    }
    
    /**
     * 初始化设置筛选条件
     * @throws IOException
     */
    public static SaveSelectionConditionBean InitSaveSelectionCondition(int MchId,int AgentId,int scope) throws ClientProtocolException, IOException{
    	SaveSelectionConditionBean saveselectionconditionBean = new SaveSelectionConditionBean();
    	saveselectionconditionBean.setUserId(MchId);
    	saveselectionconditionBean.setAgentId(AgentId);
    	saveselectionconditionBean.setScope(scope);
		return saveselectionconditionBean;
    }
    
    
    /**
     * 设置筛选条件
     * @param initSaveSelectionCondition
     * @throws IOException
     */
    public static void SaveSelectionCondition(SaveSelectionConditionBean initSaveSelectionCondition) throws ClientProtocolException, IOException{
    	SaveSelectionConditionCall saveSelectionConditionCall = new SaveSelectionConditionCall();
    	saveSelectionConditionCall.setData(false,initSaveSelectionCondition);
    	saveSelectionConditionCall.callService();
    	Logger.verifyEquals("200", saveSelectionConditionCall.getString("code"), "验证SaveSelectionCondition");
    }
    
    
    /**
     * 获取分佣条件详情
     * @param userId
     * @throws IOException
     */
    public static JsonObject GetCondictionRebate(int userId,int rebateId) throws ClientProtocolException, IOException{
		GetConditionRebateBean getconditionrebateBean = new GetConditionRebateBean();
		GetConditionRebateCall getconditionrebateCall = new GetConditionRebateCall();
		getconditionrebateBean.setUserId(userId);
		getconditionrebateBean.setConditionRebateId(rebateId);
		getconditionrebateCall.setData(false,getconditionrebateBean);
		getconditionrebateCall.callService();
		Logger.verifyEquals("200", getconditionrebateCall.getString("code"), "验证GetCondictionRebate");
		return getconditionrebateCall.getJsonObject();
    }
    
    
    /**
     * 分佣条件禁用
     * @param userId
     * @throws IOException
     */
    public static void EnableConditionRebate(int userId,int conditionRebateId,boolean enable) throws ClientProtocolException, IOException  {
    	EnableConditionRebateBean enableconditionrebateBean = new EnableConditionRebateBean();
		EnableConditionRebateCall enableconditionrebateCall = new EnableConditionRebateCall();
		enableconditionrebateBean.setConditionRebateId(conditionRebateId);
		enableconditionrebateBean.setEnable(enable);
		enableconditionrebateBean.setUserId(userId);
		enableconditionrebateCall.setData(false,enableconditionrebateBean);
		enableconditionrebateCall.callService();
		Logger.verifyEquals("200", enableconditionrebateCall.getString("code"), "验证EnableConditionRebate");
    }
    
    
    /**
     * 删除一个分佣条件
     * @param userId
     * @throws IOException
     */
    public static void DeleteConditionRebate(int userId,int conditionRebateId) throws ClientProtocolException, IOException  {
		DeleteConditionRebateBean deleteconditionrebateBean = new DeleteConditionRebateBean();
		DeleteConditionRebateCall deleteconditionrebateCall = new DeleteConditionRebateCall();
		deleteconditionrebateBean.setUserId(userId);
		deleteconditionrebateBean.setConditionRebateId(conditionRebateId);
		deleteconditionrebateCall.setData(false, deleteconditionrebateBean);
		deleteconditionrebateCall.callService();
		Logger.verifyEquals("200", deleteconditionrebateCall.getString("code"), "验证DeleteConditionRebate");
    }
    
    
    
    
    
    /**
     * 根据bean初始化一个分佣条件
     * @param bean
     * @return 
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static AddConditionRebateBean InitAddCondictionRebate(AddAgentProductBean bean) throws ClientProtocolException, IOException{
		AddConditionRebateBean addconditionrebateBean = new AddConditionRebateBean();
		addconditionrebateBean.setUserId(bean.getUserId());
		addconditionrebateBean.setBrandIdList(Arrays.asList(bean.getBrandId()));
		ArrayList<ConditionRebateValueDto> arrayList = new ArrayList<ConditionRebateValueDto>();
		bean.getCatalogList().get(0).getAgentPriceList().forEach(b->{
			arrayList.add(new ConditionRebateValueDto(b.getAgentTypeId(),new BigDecimal(20)));
		});
		addconditionrebateBean.setCatalogRebateList(arrayList);
		
		return addconditionrebateBean;
    }
    
    /**
     * 根据bean初始化一个分佣条件，按照权重设置
     * @param bean
     * @return 
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static AddConditionRebateBean InitAddCondictionRebate(AddAgentProductBean bean,int Weight) throws ClientProtocolException, IOException{
		AddConditionRebateBean addconditionrebateBean = new AddConditionRebateBean();
		addconditionrebateBean.setUserId(bean.getUserId());
		ArrayList<ConditionRebateValueDto> arrayList = new ArrayList<ConditionRebateValueDto>();
		bean.getCatalogList().get(0).getAgentPriceList().forEach(b->{
			arrayList.add(new ConditionRebateValueDto(b.getAgentTypeId(),new BigDecimal(20)));
		});
		addconditionrebateBean.setCatalogRebateList(arrayList);
		Logger.comment("按照权重创建权重为"+Weight);
		switch (Weight) {
		case 1:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean.getBrandId()));
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean.getDepotId()));
			break;
		case 2:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean.getBrandId()));
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			break;
		case 3:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean.getBrandId()));
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean.getDepotId()));
			break;
		case 4:
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean.getDepotId()));
			break;
		case 5:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean.getBrandId()));
			break;
		case 6:
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			break;
		case 7:
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean.getDepotId()));
			break;
		default:
			break;
		}
		
		return addconditionrebateBean;
    }
    
    
    /**
     * 根据bean初始化一个分佣条件，按照权重设置
     * @param bean
     * @return 
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static AddConditionRebateBean InitAddCondictionRebate(AddAgentProductBean bean1,ImportAgentProductBean bean,int Weight,int RebateValue) throws ClientProtocolException, IOException{
		AddConditionRebateBean addconditionrebateBean = new AddConditionRebateBean();
		addconditionrebateBean.setUserId(bean.getUserId());
		ArrayList<ConditionRebateValueDto> arrayList = new ArrayList<ConditionRebateValueDto>();
		bean.getCatalogList().get(0).getAgentPriceList().forEach(b->{
			arrayList.add(new ConditionRebateValueDto(b.getAgentTypeId(),new BigDecimal(RebateValue)));
		});
		
		addconditionrebateBean.setCatalogRebateList(arrayList);
		Logger.comment("按照权重创建权重为"+Weight);
		switch (Weight) {
		case 1:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean1.getBrandId()));
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean1.getDepotId()));
			break;
		case 2:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean1.getBrandId()));
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			break;
		case 3:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean1.getBrandId()));
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean1.getDepotId()));
			break;
		case 4:
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean1.getDepotId()));
			break;
		case 5:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean1.getBrandId()));
			break;
		case 6:
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			break;
		case 7:
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean1.getDepotId()));
			break;
		default:
			break;
		}
		
		return addconditionrebateBean;
    }
    
    
    /**
     * 根据bean初始化一个分佣条件，按照权重设置
     * @param bean
     * @return 
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static int AddCondictionRebate(AddAgentProductBean bean,int Weight,double rebateValue) throws ClientProtocolException, IOException{
		AddConditionRebateBean addconditionrebateBean = new AddConditionRebateBean();
		AddConditionRebateCall addconditionrebateCall = new AddConditionRebateCall();
		addconditionrebateBean.setUserId(bean.getUserId());
		ArrayList<ConditionRebateValueDto> arrayList = new ArrayList<ConditionRebateValueDto>();
		bean.getCatalogList().get(0).getAgentPriceList().forEach(b->{
			arrayList.add(new ConditionRebateValueDto(b.getAgentTypeId(),new BigDecimal(rebateValue)));
		});
		addconditionrebateBean.setCatalogRebateList(arrayList);
		Logger.comment("按照权重创建权重为"+Weight);
		switch (Weight) {
		case 1:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean.getBrandId()));
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean.getDepotId()));
			break;
		case 2:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean.getBrandId()));
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			break;
		case 3:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean.getBrandId()));
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean.getDepotId()));
			break;
		case 4:
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean.getDepotId()));
			break;
		case 5:
			addconditionrebateBean.setBrandIdList(Arrays.asList(bean.getBrandId()));
			break;
		case 6:
			addconditionrebateBean.setFirstCategoryIdList(Arrays.asList(1001));
			break;
		case 7:
			addconditionrebateBean.setDepotIdList(Arrays.asList(bean.getDepotId()));
			break;
		default:
			break;
		}
		addconditionrebateCall.setData(false,addconditionrebateBean);
		addconditionrebateCall.callService();
		Logger.verifyEquals("200", addconditionrebateCall.getString("code"), "验证AddCondictionRebate");
		return addconditionrebateCall.getRebateId();
    }
    
    
    /**
     * 新建分佣条件
     * @param bean
     * @return
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static int AddCondictionRebate(AddConditionRebateBean bean) throws ClientProtocolException, IOException{
		AddConditionRebateCall addconditionrebateCall = new AddConditionRebateCall();
		addconditionrebateCall.setData(false,bean);
		addconditionrebateCall.callService();
		Logger.verifyEquals("200", addconditionrebateCall.getString("code"), "验证AddCondictionRebate");
		return addconditionrebateCall.getRebateId();
    }
    
    /**
     * 初始化编辑返佣条件bean
     * @param RebateId
     * @param bean
     * @return
     */
    public static EditConditionRebateBean InitEditCondictionRebate(int RebateId,AddConditionRebateBean bean){
    	EditConditionRebateBean editconditionrebateBean = new EditConditionRebateBean();
    	editconditionrebateBean.setBrandIdList(bean.getBrandIdList());
    	editconditionrebateBean.setUserId(bean.getUserId());
    	editconditionrebateBean.setFirstCategoryIdList(bean.getFirstCategoryIdList());
    	editconditionrebateBean.setDepotIdList(bean.getDepotIdList());
    	editconditionrebateBean.setCatalogRebateList(bean.getCatalogRebateList());
    	editconditionrebateBean.setConditionRebateId(RebateId);
    	return editconditionrebateBean;
    }
    
    
    /**
     * 初始化修改库存与价格接口
     * @param UserId
     * @param skuId
     * @param productId
     * @return 
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static UpdateStockAndPriceBean initUpdateStockAndPrice(int UserId,String skuId,String productId) throws ClientProtocolException, IOException{
		UpdateStockAndPriceBean updatestockandpriceBean = new UpdateStockAndPriceBean();
		ProductDetailsDto agentProd = AddAgentProductCallService.selectProductDetails(UserId, productId);
		
		DetailsCatalogDto CatalogDto = agentProd.getCatalogList().stream().filter(b->b.getSku().equals(skuId)).collect(Collectors.toList()).get(0);
		updatestockandpriceBean.setUserId(UserId);
		updatestockandpriceBean.setSkuId(CatalogDto.getSku());
		updatestockandpriceBean.setRealStock(CatalogDto.getRealStock());
		updatestockandpriceBean.setVirtualStock(CatalogDto.getVirtualStock());
		updatestockandpriceBean.setSalePrice(CatalogDto.getDirectPrice());
		updatestockandpriceBean.setMarketPrice(CatalogDto.getAdvicePrice());
		updatestockandpriceBean.setMarketAmount(CatalogDto.getMarketAmount());
//		updatestockandpriceBean.setAgentPriceList(agentProd.getAgentPriceList());
		return updatestockandpriceBean; 
    }
    
    /**
     * 修改库存和价格
     * @param updatestockandpriceBean
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static void UpdateStockAndPrice(UpdateStockAndPriceBean updatestockandpriceBean) throws ClientProtocolException, IOException{
		UpdateStockAndPriceCall updatestockandpriceCall = new UpdateStockAndPriceCall();
		updatestockandpriceCall.setData(updatestockandpriceBean);
		updatestockandpriceCall.callService();
		Logger.verifyEquals("200", updatestockandpriceCall.getString("code"), "验证code");
    }
    
    
    
    /**
     * 初始化商品分佣、按照比例百分之20
     * @param productId
     * @param userId
     * @return
     * @throws InterruptedException
     * @throws IOException 
     * @throws ClientProtocolException 
     */
    public static EditProductRebateBean initEditProductRebateBean(String productId,int AgentUserId,int userId,double Rebate) throws InterruptedException, ClientProtocolException, IOException{
    	EditProductRebateBean editproductrebateBean = new EditProductRebateBean();
    	List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(ele->ele.getsCatalogId()).collect(Collectors.toList());
		editproductrebateBean.setUserId(userId);
		editproductrebateBean.setProductId(productId);
		editproductrebateBean.setRebateType(1);
		List<mch_relation> selectBymchId = new mch_relationWapper().selectByPrimaryKey(AgentUserId, userId);
		List<CatalogRebateDto> list = new ArrayList<CatalogRebateDto>();
		
		selectBymchId.forEach(b->{
			catalogs.forEach(c->{
				CatalogRebateDto catalogRebateDto = new CatalogRebateDto();
				catalogRebateDto.setAgentTypeId(b.getAgentType());
				catalogRebateDto.setCatalogId(c);
				catalogRebateDto.setRebateValue(new BigDecimal(Rebate));
				list.add(catalogRebateDto);
				System.out.println("11212312");
			});
		});
		editproductrebateBean.setCatalogRebateList(list);
		return editproductrebateBean;
    }
    /**
     *  初始化商品批量分佣、按照比例百分之20
     * @param productIds
     * @param AgentUserId
     * @param userId
     * @return
     * @throws InterruptedException
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static EditBatchProductRebateBean initEditBatchProductRebateBean(List<String> productIds,int AgentUserId,int userId) throws InterruptedException, ClientProtocolException, IOException{
    	EditBatchProductRebateBean editproductrebateBean = new EditBatchProductRebateBean();
    	editproductrebateBean.setUserId(userId);
		editproductrebateBean.setProductIds(productIds);
		editproductrebateBean.setRebateType(1);
    	productIds.forEach(productId->{
    		try {
				List<mch_relation> selectBymchId = new mch_relationWapper().selectByPrimaryKey(AgentUserId, userId);
				editproductrebateBean.setProductRebateList(
    				Arrays.asList(new ProductRebateDto(selectBymchId.get(0).getAgentType(), new BigDecimal(20))));
    		} catch (InterruptedException e) {
				e.printStackTrace();
			}
    	});
		return editproductrebateBean;
    }
    
    /**
     * 商品设置分佣
     * @param initEditProductRebateBean
     * @return
     * @throws InterruptedException
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static void EditProductRebateBean(EditProductRebateBean initEditProductRebateBean) throws InterruptedException, ClientProtocolException, IOException{
		EditProductRebateCall editproductrebateCall = new EditProductRebateCall();
		editproductrebateCall.setData(false,initEditProductRebateBean);
		editproductrebateCall.callService();			
		Logger.verifyEquals("200", editproductrebateCall.getString("code"), "验证code");
    }
    
    
    
    /**
     * 查询分佣详情
     * @return
     * @throws InterruptedException
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static JsonObject GetProductRebate(int userId,String productId) throws ClientProtocolException, IOException {
    	GetProductRebateBean getproductrebateBean = new GetProductRebateBean();
		GetProductRebateCall getproductrebateCall = new GetProductRebateCall();
		getproductrebateBean.setProductId(productId);
		getproductrebateBean.setUserId(userId);
		getproductrebateCall.setData(false,getproductrebateBean);
		getproductrebateCall.callService();			
		Logger.verifyEquals("200", getproductrebateCall.getString("code"), "验证code");
		return getproductrebateCall.getJsonObject().getAsJsonObject("data");
    }
    
    
    /**
     * 修改创建价格
     * @param addagentproductBean 已经初始化的AddAgentProductBean
     * @param directPrice 直销价-建议零售价
     * @param agentPrice 代理价
     * @return
     */
    public static AddAgentProductBean UpdateAddAgentProductPrice(AddAgentProductBean addagentproductBean,Double directPrice,Double agentPrice) {
    	addagentproductBean.getCatalogList().forEach(c->{
    		c.setDirectPrice(directPrice);
    		if(c.getAgentPriceList().size()>0) {
    			c.getAgentPriceList().forEach(ap->{
    				ap.setAgentPrice(agentPrice);
    			});
    		}else {
    			listagentTypeBean listagentTypeBean = GodmchManageCallService.InitlistgentTypeBean(addagentproductBean.getUserId());
                List<AgentTypeVo> agentTypeVos = new ArrayList<AgentTypeVo>();
				try {
					agentTypeVos = GodmchManageCallService.listgentTypeCall(listagentTypeBean).getAgentTypes();
				} catch (IOException e) {
					e.printStackTrace();
				}
                    List<AgentPriceDto> agentPriceDtos1 = new ArrayList<>();
                    agentTypeVos.forEach(x->{
                        if (x.getAgentType()!=0){
                            AgentPriceDto agentPriceDto = new AgentPriceDto();
                            agentPriceDto.setAgentTypeId(x.getAgentType());
                            double price = Double.parseDouble(1+ TestDataManager.getRandomNum(2));
                            agentPriceDto.setAgentPrice(price);
                            agentPriceDtos1.add(agentPriceDto);
                        }
                    });
                    c.setAgentPriceList(agentPriceDtos1);
    		}
    	});
    	return addagentproductBean;
    }
    
    /***
     * 创建套装组合商品
     * @param sellerId
     * @return
     * @throws Exception
     */
    public static String AddComposeAgentProduct(int sellerId) throws Exception {
    	
    	AddAgentProductBean addagentproductBean = new AddAgentProductBean();
    	AddAgentProductCall addagentproductCall = new AddAgentProductCall();
    	AddAgentProductBean Product1 = AddAgentProductCallService.initAddAgentProduct(sellerId,
				"", true);
		Product1.getCatalogList().remove(0);
		String productId1 = AddAgentProductCallService.AddAgentProduct(Product1);
		
		
		AddAgentProductBean Product2 = AddAgentProductCallService.initAddAgentProduct(sellerId,
				"", true);
		Product2.getCatalogList().remove(0);
		String productId2 = AddAgentProductCallService.AddAgentProduct(Product2);
		
		AddAgentProductBean addAgentProductBean=AddAgentProductCallService.initAddAgentProduct(sellerId,"", true);
		
		addAgentProductBean.getCatalogList().remove(1);
		SubCatalogDto subCatalogDto = new SubCatalogDto();
		subCatalogDto.setSkuId(Product1.getCatalogList().get(0).getSku());
		subCatalogDto.setBarcode(Product1.getCatalogList().get(0).getBarcode());
		subCatalogDto.setSalePrice(Product1.getCatalogList().get(0).getDirectPrice());
		subCatalogDto.setNum(10);
		
		
		SubCatalogDto subCatalogDto1 = new SubCatalogDto();
		subCatalogDto1.setSkuId(Product2.getCatalogList().get(0).getSku());
		subCatalogDto1.setBarcode(Product2.getCatalogList().get(0).getBarcode());
		subCatalogDto1.setSalePrice(Product2.getCatalogList().get(0).getDirectPrice());
		subCatalogDto1.setNum(10);
		
		addAgentProductBean.setSubCatalogs(Arrays.asList(subCatalogDto,subCatalogDto1));
		addagentproductCall.setData(addAgentProductBean);
		addagentproductCall.callService();
		Logger.verifyEquals("200", addagentproductCall.getString("code"), "验证Code");
    	
		String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId")
				.getAsString();
		return productId;
    }
    
    /**
     * 初始化代理商品发布
     * @param sellerId 商户id
     * @param sellerName 商户名称
     * @param setAgentPrice 是否设置给下级代理
     */
    public static AddAgentProductBean initAddAgentProduct(int sellerId,String sellerName,boolean setAgentPrice) throws IOException {

        AddAgentProductBean addagentproductBean = new AddAgentProductBean();
        addagentproductBean.setUserId(sellerId);
        addagentproductBean.setUserName(sellerName);
        //发布类型 1-发布上架 2-保存为下架
        addagentproductBean.setSaleType(1);
        addagentproductBean.setSetAgentPrice(setAgentPrice);
        //标题
        addagentproductBean.setTitle("God"+TestDataManager.getRandomNum(6));
        addagentproductBean.setProductCode("货号" + TestDataManager.getRandomNum(10));
        
        if (sellerId == 502665591)
        	addagentproductBean.setNationType(3);
        else
        	addagentproductBean.setNationType(2);

		addagentproductBean.setNationType(1);
        
        List<String> picList = new ArrayList<>();
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
        picList.add("http://pic1.ymatou.com/G01/M00/41/2B/rBBlD1yYU-SAJhweAADmTO2YrBw085_1_1_o.jpg");
        picList.add("http://pic1.ymatou.com/G01/M00/40/C9/rBBlD1yYTCmAZV4MAAFgY-30kgs700_1_1_o.jpg");
        //商品图片
        addagentproductBean.setPics(picList);
        //规格列表1
        CatalogDto catalogDto = new CatalogDto();
        //直销价
        catalogDto.setDirectPrice(900d);
        //catalogDto.setDirectPrice(1d);
        //库存
        catalogDto.setStock(100);
        catalogDto.setWeight(3);
        catalogDto.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        String sku1 = TestDataManager.getRandomNum(9);
        String sku2 = TestDataManager.getRandomNum(9);
        //商户商品编码
        
        if (ShenqiUserSet.cdfMembergoodsOwnerId.intValue() == sellerId)
        	catalogDto.setSku(sku1);
        else
        	catalogDto.setSku(sku1);
        //规格名称
        catalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));//已经没用
        List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
        catalogDto.setAgentPriceList(agentPriceDtos);
        CatalogPropDto catalogPropDto1 = new CatalogPropDto();
        catalogPropDto1.setName("自动化测试1_"+TestDataManager.getRandomNum(5));
        catalogPropDto1.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto1.setSubType("欧码");
        catalogPropDto1.setValue("170");
        CatalogPropDto catalogPropDto2 = new CatalogPropDto();
        catalogPropDto2.setName("自动化测试2_"+TestDataManager.getRandomNum(5));
        catalogPropDto2.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto2.setSubType("国码");
        catalogPropDto2.setValue("180");

        CatalogPropDto catalogPropDto3 = new CatalogPropDto();
        catalogPropDto3.setName("自动化测试3_"+TestDataManager.getRandomNum(5));
        catalogPropDto3.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto3.setSubType("美码");
        catalogPropDto3.setValue("190");

        CatalogPropDto catalogPropDto4 = new CatalogPropDto();
        catalogPropDto4.setName("自动化测试4_"+TestDataManager.getRandomNum(5));
        catalogPropDto4.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto4.setSubType("日码");
        catalogPropDto4.setValue("160");

        List<CatalogPropDto> propertyList1 = new ArrayList<>();
        List<CatalogPropDto> propertyList2 = new ArrayList<>();

        propertyList1.add(catalogPropDto1);
        propertyList1.add(catalogPropDto2);
        propertyList2.add(catalogPropDto3);
        propertyList2.add(catalogPropDto4);
        catalogDto.setPropertyList(propertyList1);
        //规格列表2
        CatalogDto CatalogDto = new CatalogDto();
        CatalogDto.setDirectPrice(1000d);
        CatalogDto.setStock(100);
        
        if (ShenqiUserSet.cdfMembergoodsOwnerId.intValue() == sellerId)
        	CatalogDto.setSku(sku2);
        else
        	CatalogDto.setSku(sku2);
        
        CatalogDto.setWeight(1);
        CatalogDto.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_401.jpg");
        CatalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        CatalogDto.setAgentPriceList(agentPriceDtos);
        
        CatalogDto.setPropertyList(propertyList2);
        
        List<CatalogDto> catalogDtos = new ArrayList<>();
        catalogDtos.add(catalogDto);
        catalogDtos.add(CatalogDto);

        if(setAgentPrice){
            listagentTypeBean listagentTypeBean = GodmchManageCallService.InitlistgentTypeBean(sellerId);
            List<AgentTypeVo> agentTypeVos = GodmchManageCallService.listgentTypeCall(listagentTypeBean).getAgentTypes();
            catalogDtos.forEach(p->{
                List<AgentPriceDto> agentPriceDtos1 = new ArrayList<>();
                agentTypeVos.forEach(x->{
                    if (x.getAgentType()!=0){
                        AgentPriceDto agentPriceDto = new AgentPriceDto();
                        agentPriceDto.setAgentTypeId(x.getAgentType());
//                        double price = Double.parseDouble(1+ TestDataManager.getRandomNum(2));

						double price = 900;
                        agentPriceDto.setAgentPrice(price);
                        agentPriceDtos1.add(agentPriceDto);
                    }
                });
                p.setAgentPriceList(agentPriceDtos1);
            });
        }
        addagentproductBean.setCatalogList(catalogDtos);
        addagentproductBean.setCatalogStatus(999);
        addagentproductBean.setCardInfo(0);
        addagentproductBean.setCategoryId(1002);
        addagentproductBean.setThirdCategoryId(1003);
        addagentproductBean.setBrandId(AddAgentProductCallService.BrandId);
        addagentproductBean.setRemark("测试商品");
        addagentproductBean.setCurrency("USD");
        addagentproductBean.setDescription("ceshishangping");
        addagentproductBean.setDescPicList(Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg"));
        //是否在买家端店铺首页中不可见 false 可见
        addagentproductBean.setInvisible(false);
        addagentproductBean.setExpressDelivery(true);
        addagentproductBean.setCollectionGoods(true);
        addagentproductBean.setMinOrderNum(0);
        return addagentproductBean;
    }
    
    /**
     * 初始化修改商品技术信息
     */
    public static UpdateProductBaseBean initUpdateProductBase(String productId,AddProductBean initAddProduct) throws IOException {
    	UpdateProductBaseBean updateBean = new UpdateProductBaseBean();
        updateBean.setUserId(initAddProduct.getUserId());
        updateBean.setProductId(productId);
        updateBean.setTitle(initAddProduct.getTitle());
        updateBean.setThirdCategoryId(initAddProduct.getThirdCategoryId());
        updateBean.setBrandId(initAddProduct.getBrandId());
        updateBean.setCatalogStatus(initAddProduct.getCatalogStatus());
        updateBean.setCardInfo(initAddProduct.getCardInfo());
        updateBean.setCurrency(initAddProduct.getCurrency());
        updateBean.setRemark(initAddProduct.getRemark());
        updateBean.setTariffRate(initAddProduct.getTariffRate());
        updateBean.setMarketCurrency(initAddProduct.getMarketCurrency());
        updateBean.setFreightTemplateName(initAddProduct.getFreightTemplateName());
        updateBean.setSaleType(1);
        
        return updateBean;
    }
    /**
     * 初始化修改商品技术信息
     */
    public static UpdateProductBaseBean initUpdateProductBase(String productId,AddAgentProductBean initAddProduct) throws IOException {
    	UpdateProductBaseBean updateBean = new UpdateProductBaseBean();
        updateBean.setUserId(initAddProduct.getUserId());
        updateBean.setProductId(productId);
        updateBean.setTitle(initAddProduct.getTitle());
        updateBean.setThirdCategoryId(initAddProduct.getThirdCategoryId());
        updateBean.setBrandId(initAddProduct.getBrandId());
        updateBean.setCatalogStatus(initAddProduct.getCatalogStatus());
        updateBean.setCardInfo(initAddProduct.getCardInfo());
        updateBean.setCurrency(initAddProduct.getCurrency());
        updateBean.setRemark(initAddProduct.getRemark());
        updateBean.setTariffRate(initAddProduct.getTariffRate());
        updateBean.setMarketCurrency(initAddProduct.getMarketCurrency());
        updateBean.setSaleType(1);
        return updateBean;
    }
    
    
    public static AddAgentProductBean initAddAgentProductV2(int sellerId,String sellerName,boolean setAgentPrice) throws IOException, InterruptedException {

        AddAgentProductBean addagentproductBean = new AddAgentProductBean();
        addagentproductBean.setUserId(sellerId);
        addagentproductBean.setUserName(sellerName);
        //发布类型 1-发布上架 2-保存为下架
        addagentproductBean.setSaleType(1);
        addagentproductBean.setSetAgentPrice(setAgentPrice);
        //标题
        addagentproductBean.setTitle("God");
        List<String> picList = new ArrayList<>();
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        //商品图片
        addagentproductBean.setPics(picList);
        //规格列表1
        CatalogDto catalogDto = new CatalogDto();
        //直销价
        catalogDto.setDirectPrice(900d);
        //库存
        catalogDto.setStock(100);
        String sku = TestDataManager.getRandomNum(6);
        //商户商品编码
        catalogDto.setSku(sku);
        //规格名称
        
        catalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
        catalogDto.setAgentPriceList(agentPriceDtos);


        CatalogPropDto catalogPropDto1 = new CatalogPropDto();
        catalogPropDto1.setName("自动化测试1_"+TestDataManager.getRandomNum(5));
        catalogPropDto1.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto1.setSubType("欧码");
        catalogPropDto1.setValue("170");

        CatalogPropDto catalogPropDto2 = new CatalogPropDto();
        catalogPropDto2.setName("自动化测试2_"+TestDataManager.getRandomNum(5));
        catalogPropDto2.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto2.setSubType("国码");
        catalogPropDto2.setValue("180");

        CatalogPropDto catalogPropDto3 = new CatalogPropDto();
        catalogPropDto3.setName("自动化测试3_"+TestDataManager.getRandomNum(5));
        catalogPropDto3.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto3.setSubType("美码");
        catalogPropDto3.setValue("190");

        CatalogPropDto catalogPropDto4 = new CatalogPropDto();
        catalogPropDto4.setName("自动化测试4_"+TestDataManager.getRandomNum(5));
        catalogPropDto4.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto4.setSubType("日码");
        catalogPropDto4.setValue("160");

        List<CatalogPropDto> propertyList1 = new ArrayList<>();
        List<CatalogPropDto> propertyList2 = new ArrayList<>();

        propertyList1.add(catalogPropDto1);
        propertyList1.add(catalogPropDto2);
        propertyList2.add(catalogPropDto3);
        propertyList2.add(catalogPropDto4);

        //规格列表2
        CatalogDto CatalogDto = new CatalogDto();
        CatalogDto.setDirectPrice(900d);
        CatalogDto.setStock(100);
        CatalogDto.setSku(sku);
        CatalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        CatalogDto.setAgentPriceList(agentPriceDtos);

        catalogDto.setPropertyList(propertyList1);
        CatalogDto.setPropertyList(propertyList2);

        List<CatalogDto> catalogDtos = new ArrayList<>();
        catalogDtos.add(catalogDto);
        catalogDtos.add(CatalogDto);

        if(setAgentPrice){
            Map cmap = new DefGodMchWapper().selectCsInfoByCsId(sellerId).get(0);
            listagentTypeBean listagentTypeBean = GodmchManageCallService.InitlistgentTypeBean(Integer.parseInt(cmap.get("mchId").toString()));
            List<AgentTypeVo> agentTypeVos = GodmchManageCallService.listgentTypeCall(listagentTypeBean).getAgentTypes();
            catalogDtos.forEach(p->{
                List<AgentPriceDto> agentPriceDtos1 = new ArrayList<>();
                agentTypeVos.forEach(x->{
                    AgentPriceDto agentPriceDto = new AgentPriceDto();
                    agentPriceDto.setAgentTypeId(x.getAgentType());
                    double price = Double.parseDouble(1+ TestDataManager.getRandomNum(2));
                    agentPriceDto.setAgentPrice(price);
                    agentPriceDtos1.add(agentPriceDto);
                });
                p.setAgentPriceList(agentPriceDtos1);
            });
        }
        addagentproductBean.setCatalogList(catalogDtos);
        addagentproductBean.setCatalogStatus(999);
        addagentproductBean.setCardInfo(0);
        addagentproductBean.setCategoryId(1002);
        addagentproductBean.setThirdCategoryId(1003);
        addagentproductBean.setBrandId(AddAgentProductCallService.BrandId);
        addagentproductBean.setRemark("测试商品");
        addagentproductBean.setCurrency("USD");
        addagentproductBean.setDescription("ceshishangping");
        addagentproductBean.setDescPicList(Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg"));
        addagentproductBean.setExpressDelivery(true);
        addagentproductBean.setCollectionGoods(true);
        addagentproductBean.setMinOrderNum(0);
        
        return addagentproductBean;

    }
    
    /**
     * 初始化代理商品发布含税
     * @param sellerId 商户id
     * @param sellerName 商户名称
     * @param setAgentPrice 是否设置给下级代理
     */
    public static AddAgentProductBean initAddAgentProductV3(int sellerId,String sellerName,boolean setAgentPrice) throws IOException {

        AddAgentProductBean addagentproductBean = new AddAgentProductBean();
        addagentproductBean.setUserId(sellerId);
        addagentproductBean.setUserName(sellerName);
        //发布类型 1-发布上架 2-保存为下架
        addagentproductBean.setSaleType(1);
        addagentproductBean.setSetAgentPrice(setAgentPrice);
        //标题
        addagentproductBean.setTitle("God");
        
        List<String> picList = new ArrayList<>();
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        //商品图片
        addagentproductBean.setPics(picList);
        //规格列表1
        CatalogDto catalogDto = new CatalogDto();
        //直销价
        catalogDto.setDirectPrice(900d);
        //库存
        catalogDto.setStock(100);
        catalogDto.setWeight(3);
        catalogDto.setLimitNum(10);
        catalogDto.setMarketPrice(80d);
        catalogDto.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        String sku1 = TestDataManager.getRandomNum(6);
        String sku2 = TestDataManager.getRandomNum(6);
        //商户商品编码
        catalogDto.setSku(sku1);
        //规格名称
        catalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));//已经没用
        List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
        catalogDto.setAgentPriceList(agentPriceDtos);
        
        //增加税
        addagentproductBean.setTariffRate(0.091);
        addagentproductBean.setMarketCurrency("UKD");

        CatalogPropDto catalogPropDto1 = new CatalogPropDto();
        catalogPropDto1.setName("自动化测试1_"+TestDataManager.getRandomNum(5));
        catalogPropDto1.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto1.setSubType("欧码");
        catalogPropDto1.setValue("170");

        CatalogPropDto catalogPropDto2 = new CatalogPropDto();
        catalogPropDto2.setName("自动化测试2_"+TestDataManager.getRandomNum(5));
        catalogPropDto2.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto2.setSubType("国码");
        catalogPropDto2.setValue("180");

        CatalogPropDto catalogPropDto3 = new CatalogPropDto();
        catalogPropDto3.setName("自动化测试3_"+TestDataManager.getRandomNum(5));
        catalogPropDto3.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto3.setSubType("美码");
        catalogPropDto3.setValue("190");

        CatalogPropDto catalogPropDto4 = new CatalogPropDto();
        catalogPropDto4.setName("自动化测试4_"+TestDataManager.getRandomNum(5));
        catalogPropDto4.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto4.setSubType("日码");
        catalogPropDto4.setValue("160");

        List<CatalogPropDto> propertyList1 = new ArrayList<>();
        List<CatalogPropDto> propertyList2 = new ArrayList<>();

        propertyList1.add(catalogPropDto1);
        propertyList1.add(catalogPropDto2);
        propertyList2.add(catalogPropDto3);
        propertyList2.add(catalogPropDto4);
        catalogDto.setPropertyList(propertyList1);
        //规格列表2
        CatalogDto CatalogDto = new CatalogDto();
        CatalogDto.setDirectPrice(900d);
        CatalogDto.setStock(100);
        CatalogDto.setSku(sku2);
        CatalogDto.setWeight(1);
        //增加限购和免税店价格
        CatalogDto.setLimitNum(10);
        CatalogDto.setMarketPrice(80.80);
        CatalogDto.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_401.jpg");
        CatalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        CatalogDto.setAgentPriceList(agentPriceDtos);

        CatalogDto.setPropertyList(propertyList2);

        List<CatalogDto> catalogDtos = new ArrayList<>();
        catalogDtos.add(catalogDto);
        catalogDtos.add(CatalogDto);

        if(setAgentPrice){
            listagentTypeBean listagentTypeBean = GodmchManageCallService.InitlistgentTypeBean(sellerId);
            List<AgentTypeVo> agentTypeVos = GodmchManageCallService.listgentTypeCall(listagentTypeBean).getAgentTypes();
            catalogDtos.forEach(p->{
                List<AgentPriceDto> agentPriceDtos1 = new ArrayList<>();
                agentTypeVos.forEach(x->{
                    if (x.getAgentType()!=0){
                        AgentPriceDto agentPriceDto = new AgentPriceDto();
                        agentPriceDto.setAgentTypeId(x.getAgentType());
                        double price = Double.parseDouble(1+ TestDataManager.getRandomNum(2));
                        agentPriceDto.setAgentPrice(price);
                        agentPriceDtos1.add(agentPriceDto);
                    }
                });
                p.setAgentPriceList(agentPriceDtos1);
            });
        }
        addagentproductBean.setCatalogList(catalogDtos);
        addagentproductBean.setCatalogStatus(999);
        addagentproductBean.setCardInfo(0);
        addagentproductBean.setCategoryId(1002);
        addagentproductBean.setThirdCategoryId(1003);
        addagentproductBean.setBrandId(AddAgentProductCallService.BrandId);
        addagentproductBean.setRemark("测试商品");
        addagentproductBean.setCurrency("USD");
        addagentproductBean.setDescription("ceshishangping");
        addagentproductBean.setDescPicList(Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg"));
        //是否在买家端店铺首页中不可见 false 可见
        addagentproductBean.setInvisible(false);
        addagentproductBean.setExpressDelivery(true);
        addagentproductBean.setCollectionGoods(true);
        addagentproductBean.setMinOrderNum(0);
        return addagentproductBean;

    }
    
    public static AddAgentProductBean initVideo(AddAgentProductBean addAgentProductBean){
    	VideoDto video=new VideoDto();
		video.setUrl("http://v2.ymatou.com/uploads/20180122/6a44924f0b4968e88321231061a3704b4cf.mp4");
		video.setLength(11173);
		video.setPic("http://pic1.ymatou.com/G01/shangou/add/3B/22/rBBlD1pMi123OCAWitxAADUmGEFNI0402_1_1_n_w_o.jpg");
		video.setWidth(440);
		video.setHeight(410);
		video.setSize(307218);
		addAgentProductBean.setVideo(video);
		return addAgentProductBean;
    }

    public static AddAgentProductBean initAddAgentProductV2(int sellerId,String sellerName,int count,boolean setAgentPrice) throws IOException {

        AddAgentProductBean addagentproductBean = new AddAgentProductBean();
        addagentproductBean.setUserId(sellerId);
        addagentproductBean.setUserName(sellerName);
        //发布类型 1-发布上架 2-保存为下架
        addagentproductBean.setSaleType(1);
        addagentproductBean.setSetAgentPrice(setAgentPrice);
        //标题
        addagentproductBean.setTitle("God");
        List<String> picList = new ArrayList<>();
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        //商品图片
        addagentproductBean.setPics(picList);
        List<CatalogDto> catalogDtos = new ArrayList<>();
        for (int i=0;i<count;i++){
            //规格列表1
            CatalogDto catalogDto = new CatalogDto();
            //直销价
            catalogDto.setDirectPrice(900d+i);
            //库存
            catalogDto.setStock(100);
            //商户商品编码
            catalogDto.setSku(TestDataManager.getRandomNum(6));
            //规格名称
            catalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
            CatalogPropDto catalogPropDto1 = new CatalogPropDto();
            catalogPropDto1.setName("自动化测试1_"+TestDataManager.getRandomNum(5));
            catalogPropDto1.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
            catalogPropDto1.setSubType("欧码");
            catalogPropDto1.setValue("170"+TestDataManager.getRandomNum(5));
            List<CatalogPropDto> propertyList = new ArrayList<>();
            propertyList.add(catalogPropDto1);
            catalogDto.setPropertyList(propertyList);
            catalogDtos.add(catalogDto);
        }
        if(setAgentPrice){
            listagentTypeBean listagentTypeBean = GodmchManageCallService.InitlistgentTypeBean(sellerId);
            List<AgentTypeVo> agentTypeVos = GodmchManageCallService.listgentTypeCall(listagentTypeBean).getAgentTypes();
            catalogDtos.forEach(p->{
                List<AgentPriceDto> agentPriceDtos1 = new ArrayList<>();
                agentTypeVos.forEach(x->{
                    AgentPriceDto agentPriceDto = new AgentPriceDto();
                    agentPriceDto.setAgentTypeId(x.getAgentType());
                    double price = Double.parseDouble(1+ TestDataManager.getRandomNum(2));
                    agentPriceDto.setAgentPrice(price);
                    agentPriceDtos1.add(agentPriceDto);
                });
                p.setAgentPriceList(agentPriceDtos1);
            });
        }
        addagentproductBean.setCatalogList(catalogDtos);
        addagentproductBean.setCatalogStatus(999);
        addagentproductBean.setCardInfo(0);
        addagentproductBean.setCategoryId(1002);
        addagentproductBean.setThirdCategoryId(1003);
        addagentproductBean.setBrandId(AddAgentProductCallService.BrandId);
        addagentproductBean.setRemark("测试商品");
        addagentproductBean.setCurrency("USD");
        addagentproductBean.setDescription("ceshishangping");
        addagentproductBean.setDescPicList(Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg"));
        return addagentproductBean;

    }

    /**
     * 发布代理商品
     * @param agentProductBean
     * @return
     * @throws IOException
     */
    public static String AddAgentProduct(AddAgentProductBean agentProductBean) throws IOException {
        AddAgentProductCall addAgentProductCall = new AddAgentProductCall();
        addAgentProductCall.setData(agentProductBean);
        addAgentProductCall.callService();
        return addAgentProductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
    }
    
    
    /**
     * 发布含税代理商品
     * @param agentProductBean
     * @return
     * @throws IOException
     */
    public static String AddAgentProduct1(AddAgentProductBean agentProductBean) throws IOException {
        AddAgentProductCall addAgentProductCall = new AddAgentProductCall();
        addAgentProductCall.setData(agentProductBean);
        addAgentProductCall.callService();
        return addAgentProductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
    }

    /**
     * 渠道商编辑商品bean
     * @param productId
     * @param agentProductBean
     * @return
     * @throws InterruptedException
     */
    public static ModifyAgentProductBean initModifyAgentProductBean(String productId,AddAgentProductBean agentProductBean) throws InterruptedException {
        ModifyAgentProductBean modifyAgentProductBean = new ModifyAgentProductBean();
        modifyAgentProductBean.setUserId(agentProductBean.getUserId());
        modifyAgentProductBean.setUserName(agentProductBean.getUserName());
        modifyAgentProductBean.setProductId(productId);
        modifyAgentProductBean.setSaleType(1);
        modifyAgentProductBean.setTitle(agentProductBean.getTitle());
        modifyAgentProductBean.setPics(agentProductBean.getPics());
        modifyAgentProductBean.setSetAgentPrice(agentProductBean.getSetAgentPrice());
        modifyAgentProductBean.setCatalogStatus(agentProductBean.getCatalogStatus());
        modifyAgentProductBean.setCardInfo(agentProductBean.getCardInfo());
        modifyAgentProductBean.setCategoryId(agentProductBean.getCategoryId());
        modifyAgentProductBean.setThirdCategoryId(agentProductBean.getThirdCategoryId());
        modifyAgentProductBean.setBrandId(agentProductBean.getBrandId());
        modifyAgentProductBean.setRemark(agentProductBean.getRemark());
        modifyAgentProductBean.setFreightTemplateId(agentProductBean.getFreightTemplateId()==null?0:agentProductBean.getFreightTemplateId());
        modifyAgentProductBean.setCurrency(agentProductBean.getCurrency());
        modifyAgentProductBean.setVideo(agentProductBean.getVideo());
        List<ModifyCatalogDto> catalogDtos = new ArrayList<>();
        List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
        YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
        ymtCatalogsIList.forEach(p->{
            ModifyCatalogDto catalogDto = new ModifyCatalogDto();
            catalogDto.setSku(p.getsSKU());
            catalogDto.setStock(p.getiNum());
            catalogDto.setCatalogId(p.getsCatalogId());
            catalogDto.setOperateType(1);
            catalogDto.setWeight(p.getWeight().doubleValue());
            catalogDto.setDirectPrice(p.getfQuotePrice().doubleValue());
            catalogDto.setPic(p.getsPicUrl());
            List<CatalogPropDto> propertyList = new ArrayList<>();
            List<Map<String,Object>> map = ipm.selectCatalogProAndValByCatalogId(p.getsCatalogId());
            map.forEach(x->{
                CatalogPropDto catalogPropDto = new CatalogPropDto();
                catalogPropDto.setValue(x.get("sCategoryAttribute").toString());
                catalogPropDto.setSubType(x.get("SubType")==null?"":x.get("SubType").toString());
                catalogPropDto.setPic(x.get("sPicUrl").toString());
                catalogPropDto.setName(x.get("sProductProperty").toString());
                propertyList.add(catalogPropDto);
            });
            catalogDto.setPropertyList(propertyList);
            catalogDtos.add(catalogDto);
        });
        modifyAgentProductBean.setCatalogList(catalogDtos);

        if (agentProductBean.getSetAgentPrice()){
            catalogDtos.forEach(p->{
                List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
                ymtProductsIWapper.selectAgentPriceById(p.getCatalogId()).forEach(x->{
                    if(x.getAgentTypeId()!=0){
                        AgentPriceDto agentPriceDto = new AgentPriceDto();
                        agentPriceDto.setAgentTypeId(x.getAgentTypeId());
                        agentPriceDto.setAgentPrice(x.getAgentPrice());
                        agentPriceDtos.add(agentPriceDto);
                    }
                });
                p.setAgentPriceList(agentPriceDtos);
            });
        }
        modifyAgentProductBean.setCatalogList(catalogDtos);
        modifyAgentProductBean.setDescPicList(agentProductBean.getDescPicList());
        modifyAgentProductBean.setDescription(agentProductBean.getDescription());
        modifyAgentProductBean.setInvisible(agentProductBean.isInvisible());
        modifyAgentProductBean.setExpressDelivery(agentProductBean.getExpressDelivery());
        modifyAgentProductBean.setCollectionGoods(agentProductBean.getCollectionGoods());
        modifyAgentProductBean.setMinOrderNum(agentProductBean.getMinOrderNum());
        modifyAgentProductBean.setProductParam(agentProductBean.getProductParam());
        
        return modifyAgentProductBean;
    }

    public static ModifyAgentProductBean initModifyAgentProductBeanByImportant(String productId,ImportAgentProductBean importAgentProductBean) throws InterruptedException {

    	
        ModifyAgentProductBean modifyAgentProductBean = new ModifyAgentProductBean();
        modifyAgentProductBean.setUserId(importAgentProductBean.getUserId());
        modifyAgentProductBean.setUserName(importAgentProductBean.getUserName());
        modifyAgentProductBean.setProductId(productId);
        modifyAgentProductBean.setSaleType(1);
        modifyAgentProductBean.setTitle(importAgentProductBean.getTitle());
        modifyAgentProductBean.setPics(importAgentProductBean.getPics());
        modifyAgentProductBean.setSetAgentPrice(importAgentProductBean.isSetAgentPrice());
        YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
        String rootProductId = ymtProductsIWapper.selectAgentProductByProductId(productId).getRootProductId();
        YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(rootProductId).get(0);
        AgentProductPo agentProductPo = ymtProductsIWapper.selectAgentProductByProductId(rootProductId);
        modifyAgentProductBean.setCurrency(agentProductPo.getCurrency());
        modifyAgentProductBean.setCatalogStatus(ymtProductsI.getiCatalogStatus());
        modifyAgentProductBean.setCardInfo(ymtProductsI.getCardInfo());
        modifyAgentProductBean.setCategoryId(ymtProductsI.getiCategoryId());
        modifyAgentProductBean.setThirdCategoryId(ymtProductsI.getiThirdCategoryId());
        modifyAgentProductBean.setBrandId(ymtProductsI.getiBrandId());
        modifyAgentProductBean.setRemark(importAgentProductBean.getRemark());

        List<ModifyCatalogDto> catalogDtos = new ArrayList<>();
        List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
        ymtCatalogsIList.forEach(p->{
            List<Map<String,Object>> map = ipm.selectCatalogProAndValByCatalogId(p.getsCatalogId());
            Logger.debug("map:"+map);
            List<CatalogPropDto> propertyList = new ArrayList<>();
            map.forEach(x->{
                CatalogPropDto catalogPropDto = new CatalogPropDto();
                catalogPropDto.setValue(x.get("sCategoryAttribute").toString());
                catalogPropDto.setSubType(x.get("SubType").toString());
                catalogPropDto.setPic(x.get("sPicUrl").toString());
                catalogPropDto.setName(x.get("sProductProperty").toString());
                propertyList.add(catalogPropDto);
            });
            ModifyCatalogDto catalogDto = new ModifyCatalogDto();
            catalogDto.setSku(p.getsSKU());
            catalogDto.setPropertyList(propertyList);
            try {
                YmtCatalogsI ymtCatalogsI = new YmtCatalogsIWapper().selectCatalogsByCatalogId(p.getRootCatalogId());
                catalogDto.setStock(ymtCatalogsI.getiNum());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            catalogDto.setCatalogId(p.getsCatalogId());
            catalogDto.setOperateType(1);
            catalogDto.setDirectPrice(p.getfQuotePrice().doubleValue());
            catalogDtos.add(catalogDto);
        });
        modifyAgentProductBean.setCatalogList(catalogDtos);
        if (importAgentProductBean.isSetAgentPrice()){
            catalogDtos.forEach(p->{
                List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
                ymtProductsIWapper.selectAgentPriceById(p.getCatalogId()).forEach(x->{
                    if(x.getAgentTypeId()>0){
                        AgentPriceDto agentPriceDto = new AgentPriceDto();
                        agentPriceDto.setAgentTypeId(x.getAgentTypeId());
                        agentPriceDto.setAgentPrice(x.getAgentPrice());
                        agentPriceDtos.add(agentPriceDto);
                    }
                });
                p.setAgentPriceList(agentPriceDtos);
            });
        }
        modifyAgentProductBean.setCatalogList(catalogDtos);
        modifyAgentProductBean.setDescription(importAgentProductBean.getDescription());
        modifyAgentProductBean.setDescPicList(importAgentProductBean.getDescPicList());
        modifyAgentProductBean.setInvisible(importAgentProductBean.isInvisible());
        return modifyAgentProductBean;
    }


    /**
     * 编辑商品
     * @param modifyAgentProductBean
     * @throws IOException
     */
    public static void modifyAgentProduct(ModifyAgentProductBean modifyAgentProductBean) throws IOException {
        ModifyAgentProductCall modifyAgentProductCall = new ModifyAgentProductCall();
        modifyAgentProductCall.setData(false,modifyAgentProductBean);
        modifyAgentProductCall.callService();
    }

    /**
     * 初始化导入商品到我的小铺Bean
     * @param sellerId 商户Id
     * @param sellerName 商户名称
     * @param parentProductId 上级商品Id
     * @param parentUserId 上级商户Id
     * @return
     */
	public static ImportAgentProductBean initImportAgentProduct(int sellerId,String sellerName,String parentProductId,int parentUserId,boolean isSetAgentPrice) throws InterruptedException, IOException {
        ImportAgentProductBean importAgentProductBean = new ImportAgentProductBean();
        importAgentProductBean.setUserId(sellerId);
        importAgentProductBean.setUserName(sellerName);
        importAgentProductBean.setTitle("导入测试商品"+TestDataManager.getRandomNum(6));
        List<String> picList = new ArrayList<>();
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        importAgentProductBean.setPics(picList);
        
        importAgentProductBean.setRemark("测试商品");
        importAgentProductBean.setParentUserId(parentUserId);
        importAgentProductBean.setParentProductId(parentProductId);
        importAgentProductBean.setSetAgentPrice(isSetAgentPrice);

        List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(parentProductId);

        List<CatalogDto> catalogDtos = new ArrayList<>();
        ymtCatalogsIList.forEach(p->{
            CatalogDto catalogDto = new CatalogDto();
            catalogDto.setAgentPriceList(null);
            if (new YmtProductsIWapper().selectAgentPriceById(p.getsCatalogId()).size()!=0){
                AgentPricePo agentPricePo = new YmtProductsIWapper().selectAgentPriceById(p.getsCatalogId()).get(0);
                catalogDto.setDirectPrice(agentPricePo.getAgentPrice() + 100);
            }else{
                catalogDto.setDirectPrice(300d);
            }
            catalogDto.setStock(p.getiNum());
            catalogDto.setSku(p.getsSKU());
            catalogDto.setPropertyValue(TestDataManager.getRandomNum(6));
            catalogDto.setParentCatalogId(p.getsCatalogId());
            catalogDto.setWeight(p.getWeight().doubleValue());

            List<CatalogPropDto> propertyList = new ArrayList<>();
            List<Map<String,Object>> map = ipm.selectCatalogProAndValByCatalogId(p.getsCatalogId());
            map.forEach(x->{
                CatalogPropDto catalogPropDto = new CatalogPropDto();
                catalogPropDto.setValue(x.get("sCategoryAttribute").toString());
                catalogPropDto.setSubType(x.get("SubType")==null?"":x.get("SubType").toString());
                catalogPropDto.setPic(x.get("sPicUrl").toString());
                catalogPropDto.setName(x.get("sProductProperty").toString());
                propertyList.add(catalogPropDto);
            });

            catalogDto.setPropertyList(propertyList);
            catalogDtos.add(catalogDto);
        });
        importAgentProductBean.setCatalogList(catalogDtos);

        if(isSetAgentPrice){
            listagentTypeBean listagentTypeBean = GodmchManageCallService.InitlistgentTypeBean(sellerId);
            List<AgentTypeVo> agentTypeVos = GodmchManageCallService.listgentTypeCall(listagentTypeBean).getAgentTypes();
            catalogDtos.forEach(p->{
                List<AgentPriceDto> agentPriceDtos1 = new ArrayList<>();
                agentTypeVos.forEach(x->{
                    AgentPriceDto agentPriceDto = new AgentPriceDto();
                    agentPriceDto.setAgentTypeId(x.getAgentType());
                    AgentPricePo agentPricePo = new YmtProductsIWapper().selectAgentPriceById(p.getParentCatalogId()).get(0);
                    double price = agentPricePo.getAgentPrice()+100;
                    agentPriceDto.setAgentPrice(price);
                    agentPriceDtos1.add(agentPriceDto);
                });
                p.setAgentPriceList(agentPriceDtos1);
            });
        }

        importAgentProductBean.setDescPicList(Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg"));
        importAgentProductBean.setDescription("ceshishangping");
        importAgentProductBean.setCatalogList(catalogDtos);
        importAgentProductBean.setInvisible(false);
   
        return importAgentProductBean;
    }



    /**
     * 导入商品到我的小铺
     * @param importAgentProductBean
     * @return
     * @throws IOException
     */
    public static String ImportAgentProduct(ImportAgentProductBean importAgentProductBean) throws IOException {
        ImportAgentProductCall importAgentProductCall = new ImportAgentProductCall();
        importAgentProductCall.setData(importAgentProductBean);
        importAgentProductCall.callService();
        return importAgentProductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
    }

    /**
     * 初始化我的商品列表Bean
     * @param userId
     * @return
     */
    public static GetProductListBean initGetProductListBean(int userId){
        GetProductListBean getProductListBean = new GetProductListBean();
        getProductListBean.setUserId(userId);
        getProductListBean.setCsId(0);
        getProductListBean.setTitle(null);
        getProductListBean.setStatus(1);
        getProductListBean.setAgentType(-1);
        getProductListBean.setPageIndex(1);
        getProductListBean.setPageSize(10);
        return getProductListBean;
    }
    
    /**
     * 获取我的商品列表
     * @param initGetProductListBean
     * @return
     * @throws Exception 
     */
    public static List<ProductListDto> GetProductListCall(GetProductListBean initGetProductListBean) throws Exception{
    	GetProductListCall call=new GetProductListCall();
    	call.setData(initGetProductListBean);
    	call.callService();
        return call.getProductList();
    }
    
    /**
     * 获取我的商品列表ToJsonObject
     * @param initGetProductListBean
     * @return
     * @throws Exception 
     */
    public static JsonObject GetProductListCallToJsonobject(GetProductListBean initGetProductListBean) throws Exception{
    	GetProductListCall call=new GetProductListCall();
    	call.setData(initGetProductListBean);
    	call.callService();
        return call.getJsonObject();
    }
    
	/**
	 * 快速获取我的商品列表
	 * 
	 * @param userId
	 * @return
	 * @throws Exception
	 */
	public static List<ProductListDto> GetProductLists(int userId) throws Exception {
		GetProductListBean getProductListBean = new GetProductListBean();
		getProductListBean.setUserId(userId);
		getProductListBean.setCsId(0);
		getProductListBean.setTitle(null);
		getProductListBean.setStatus(1);
		getProductListBean.setAgentType(-1);
		getProductListBean.setPageIndex(1);
		getProductListBean.setPageSize(10);
		GetProductListCall call = new GetProductListCall();
		call.setData(false,getProductListBean);
		call.callService();
		return call.getProductList();
	}

    /**
     * 获取商品详情
     * @param productUserId 商品属于商户id
     * @param userId 当前商户id
     * @param productId 商品id
     * @param showAllCatalog 是否显示所有规格
     * @return
     */
    public static ProductDetailsBean initGetProductDetails(int productUserId,int userId,String productId,boolean showAllCatalog){
        ProductDetailsBean productDetailsBean = new ProductDetailsBean();
        productDetailsBean.setProductId(productId);
        productDetailsBean.setProductUserId(productUserId);
        productDetailsBean.setUserId(userId);
        
        productDetailsBean.setShowAllCatalog(showAllCatalog);
        return productDetailsBean;
    }
    
   
    /**
     *            获取套装规格列表
     * @param sellerId
     * @param catalogIdList
     * @return
     * @throws Exception
     */
    public static JsonObject GetPackageInfoByCatalogIdList(int sellerId,List<String> catalogIdList) throws  Exception{
    	GetPackageInfoByCatalogIdListBean getpackageinfobycatalogidlistBean = new GetPackageInfoByCatalogIdListBean();
		GetPackageInfoByCatalogIdListCall getpackageinfobycatalogidlistCall = new GetPackageInfoByCatalogIdListCall();
		
		getpackageinfobycatalogidlistBean.setCatalogIdList(catalogIdList);
		getpackageinfobycatalogidlistBean.setSellerId(sellerId);
		getpackageinfobycatalogidlistCall.setData(getpackageinfobycatalogidlistBean);
		getpackageinfobycatalogidlistCall.callService();			
		Logger.verifyEquals("200", getpackageinfobycatalogidlistCall.getString("code"), "验证code");
		return getpackageinfobycatalogidlistCall.getJsonObject();
    }
    
    
    /**
     * 快速查询商品详情
     * @param userId 当前商户id
     * @param productId 商品id
     * @return
     * @throws IOException 
     * @throws ClientProtocolException 
     */
    
    public static ProductDetailsDto selectProductDetails(int userId,String productId) throws ClientProtocolException, IOException{
        ProductDetailsBean productDetailsBean = new ProductDetailsBean();
        productDetailsBean.setProductId(productId);
        productDetailsBean.setProductUserId(userId);
        productDetailsBean.setUserId(userId);
        productDetailsBean.setShowAllCatalog(true);
        ProductDetailsCall productDetailsCall = new ProductDetailsCall();
        productDetailsCall.setData(productDetailsBean);
        productDetailsCall.callService();
        return productDetailsCall.getProductDetails();
    }

    /**
     * 获取商品详情
     * @param productDetailsBean
     * @return 
     * @throws IOException
     */
    public static ProductDetailsDto GetProductDetails(ProductDetailsBean productDetailsBean) throws IOException {
        ProductDetailsCall productDetailsCall = new ProductDetailsCall();
        productDetailsCall.setData(productDetailsBean);
        productDetailsCall.callService();
        return productDetailsCall.getProductDetails();
    }
    
    
    /**
     * 获取商品详情
     * @param productDetailsBean
     * @throws IOException
     */
    public static JsonObject GetProductDetailsJson(ProductDetailsBean productDetailsBean) throws IOException {
        ProductDetailsCall productDetailsCall = new ProductDetailsCall();
        productDetailsCall.setData(productDetailsBean);
        productDetailsCall.callService();
        return productDetailsCall.getJsonObject();
    }
    
    /**
     * 获取商品详情
     * @param productDetailsBean
     * @throws IOException
     */
    public static ProductDetailsDto GetProductDetailsCall(ProductDetailsBean productDetailsBean) throws IOException {
        ProductDetailsCall productDetailsCall = new ProductDetailsCall();
        productDetailsCall.setData(productDetailsBean);
        productDetailsCall.callService();
        return productDetailsCall.getProductDetails();
    }

    /**
     * 获取待下单商品列表Bean
     * @param userId
     * @return
     */
   public static OrderProductListBean initOrderProductListBean(int userId){
       OrderProductListBean orderProductListBean = new OrderProductListBean();
       orderProductListBean.setUserId(userId);
       orderProductListBean.setTitle(null);
       orderProductListBean.setSecondCategoryId(0);
       orderProductListBean.setPageIndex(1);
       orderProductListBean.setPageSize(10);
       return  orderProductListBean;
   }


    /**
     * 获取代下单商品列表
     * @param orderProductListBean
     * @throws IOException
     */
    public static void OrderProductList(OrderProductListBean orderProductListBean) throws IOException {
        OrderProductListCall orderProductListCall = new OrderProductListCall();
        orderProductListCall.setData(orderProductListBean);
        orderProductListCall.callService();
    }

    /**
     * 选货中心
     * @param userId 商户id
     * @param channelUserId 渠道商id
     * @return
     */
    public static SelectionListBean initSelectionListBean(int userId,int channelUserId){
        SelectionListBean selectionListBean = new SelectionListBean();
        selectionListBean.setUserId(userId);
        selectionListBean.setChannelUserId(channelUserId);
        selectionListBean.setTitle(null);
        selectionListBean.setPageIndex(1);
        selectionListBean.setPageSize(10);
        return selectionListBean;
    }

    /**
     * 商品上架
     * @param productId
     * @param userid
     * @throws IOException
     */
    public static void SetOnshelf(String productId,int userid) throws IOException {
        SetOnshelfBean setOnshelfBean = new SetOnshelfBean();
        SetOnshelfCall setOnshelfCall = new SetOnshelfCall();
        setOnshelfBean.setProductId(productId);
        setOnshelfBean.setUserId(userid);
        setOnshelfCall.setData(setOnshelfBean);
        setOnshelfCall.callService();
    }

    /**
     * 商品下架
     * @param productId
     * @param userid
     * @throws IOException
     */
    public static void SetOffshelf(String productId,int userid) throws IOException {
        SetOffshelfBean setOffshelfBean = new SetOffshelfBean();
        SetOffshelfCall setOffshelfCall = new SetOffshelfCall();
        setOffshelfBean.setProductId(productId);
        setOffshelfBean.setUserId(userid);
        setOffshelfCall.setData(setOffshelfBean);
        setOffshelfCall.callService();
    }
    

    /**
     * 删除商品
     * @param productId
     * @param userId
     * @throws IOException
     */
    public static void DeleteProduct(String productId,int userId) throws IOException {
        DeleteProductBean deleteProductBean = new DeleteProductBean();
        DeleteProductCall deleteProductCall = new DeleteProductCall();
        deleteProductBean.setProductId(productId);
        deleteProductBean.setUserId(userId);
        deleteProductCall.setData(deleteProductBean);
        deleteProductCall.callService();
    }


    public static FastImportProductBean initFastImportProductBean(int userId){
        FastImportProductBean fastImportProductBean  = new FastImportProductBean();
        fastImportProductBean.setProductName("快速导入商品"+TestDataManager.getRandomNum(6));
        fastImportProductBean.setUserId(userId);
        fastImportProductBean.setRemark("测试");
        List<String> picList = new ArrayList<>();
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        fastImportProductBean.setProductPicList(picList);
        fastImportProductBean.setDescription("ceshishangping");
        fastImportProductBean.setDescPicList(Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg"));
//        fastImportProductBean.set
        //规格列表1
        CatalogDto catalogDto = new CatalogDto();
        //直销价
        catalogDto.setDirectPrice(900d);
        //库存
        catalogDto.setStock(100);
        catalogDto.setWeight(3);
        String sku = TestDataManager.getRandomNum(6);
        //商户商品编码
        catalogDto.setSku(sku);
        //规格名称
        catalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
        catalogDto.setAgentPriceList(agentPriceDtos);

        //规格列表2
        CatalogDto CatalogDto = new CatalogDto();
        CatalogDto.setDirectPrice(900d);
        CatalogDto.setStock(100);
        CatalogDto.setSku(sku);
        CatalogDto.setWeight(1);
        CatalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        CatalogDto.setAgentPriceList(agentPriceDtos);

        
        List<CatalogDto> catalogDtos = new ArrayList<>();
        catalogDtos.add(catalogDto);
        catalogDtos.add(CatalogDto);
       
        fastImportProductBean.setCatalogList(catalogDtos);

        return fastImportProductBean;
    }
    
    public static FastImportProductBean initFastImportProductBeanV2(int userId){
        FastImportProductBean fastImportProductBean  = new FastImportProductBean();
        fastImportProductBean.setProductName("快速导入商品"+TestDataManager.getRandomNum(6));
        fastImportProductBean.setUserId(userId);
        fastImportProductBean.setRemark("测试");
        List<String> picList = new ArrayList<>();
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        fastImportProductBean.setProductPicList(picList);
        fastImportProductBean.setDescription("ceshishangping");
        fastImportProductBean.setDescPicList(Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg"));

        //规格列表1
        CatalogDto catalogDto = new CatalogDto();
        //直销价
        catalogDto.setDirectPrice(900d);
        //库存
        catalogDto.setStock(100);
        catalogDto.setWeight(3);
        String sku = TestDataManager.getRandomNum(6);
        //商户商品编码
        catalogDto.setSku(sku);
        //规格名称
        catalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
        catalogDto.setAgentPriceList(agentPriceDtos);

        //规格列表2
        CatalogDto CatalogDto = new CatalogDto();
        CatalogDto.setDirectPrice(900d);
        CatalogDto.setStock(100);
        CatalogDto.setSku(sku);
        CatalogDto.setWeight(1);
        CatalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        CatalogDto.setAgentPriceList(agentPriceDtos);

        List<CatalogDto> catalogDtos = new ArrayList<>();
        catalogDtos.add(catalogDto);
        catalogDtos.add(CatalogDto);
        fastImportProductBean.setCatalogList(catalogDtos);
        fastImportProductBean.setProductCode(TestDataManager.getRandomNum(6));
        fastImportProductBean.setThirdCategoryId(1003);
        fastImportProductBean.setBrandId(AddAgentProductCallService.BrandId);
        fastImportProductBean.setCatalogStatus(999);
        fastImportProductBean.setCardInfo(0);
        fastImportProductBean.setTariffRate(0.09);

        return fastImportProductBean;
    }

    /**
     * 初始化保存规格属性Bean
     * @param sellerId
     * @return
     */
    public static SaveCatalogPropertyBean initSaveCatalogPropertyBean(int sellerId){
        SaveCatalogPropertyBean saveCatalogPropertyBean = new SaveCatalogPropertyBean();
        saveCatalogPropertyBean.setUserId(sellerId);
        CatalogPropDto catalogPropDto = new CatalogPropDto();
        catalogPropDto.setName("Test"+TestDataManager.getRandomNum(6));
        catalogPropDto.setValue("铁胆神猴");
//        catalogPropDto.setPic("");
        catalogPropDto.setSubType("宋");
        List<CatalogPropDto> catalogPropDtos = new ArrayList<>();
        catalogPropDtos.add(catalogPropDto);
        saveCatalogPropertyBean.setPropertyList(catalogPropDtos);
        return saveCatalogPropertyBean;
    }
    
    
    /**
     * 初始化创建商品
     * @param sellerId 商户id
     * @param sellerName 商户名称
     * @param setAgentPrice 是否设置给下级代理
     */
    public static AddProductBean initAddProduct(int sellerId,String sellerName,boolean setAgentPrice) throws IOException {

        AddProductBean addproductBean = new AddProductBean();
        addproductBean.setUserId(sellerId);
        addproductBean.setUserName(sellerName);
        //发布类型 1-发布上架 2-保存为下架
        addproductBean.setSaleType(1);
        addproductBean.setSetAgentPrice(setAgentPrice);
        //标题
        addproductBean.setTitle("God"+TestDataManager.getRandomNum(6));
        
        List<String> picList = new ArrayList<>();
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
        picList.add("http://pic1.ymatou.com/G01/M00/41/2B/rBBlD1yYU-SAJhweAADmTO2YrBw085_1_1_o.jpg");
        picList.add("http://pic1.ymatou.com/G01/M00/40/C9/rBBlD1yYTCmAZV4MAAFgY-30kgs700_1_1_o.jpg");
        //商品图片
        addproductBean.setPics(picList);
        //规格列表1
        CatalogDto catalogDto = new CatalogDto();
        //直销价
        catalogDto.setDirectPrice(900d);
        //catalogDto.setDirectPrice(1d);
        //库存
        catalogDto.setStock(100);
        catalogDto.setWeight(3);
        catalogDto.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        String sku1 = TestDataManager.getRandomNum(6);
        String sku2 = TestDataManager.getRandomNum(6);
        //商户商品编码
        catalogDto.setSku(sku1);
        //规格名称
        catalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));//已经没用
        List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
        catalogDto.setAgentPriceList(agentPriceDtos);
        

        CatalogPropDto catalogPropDto1 = new CatalogPropDto();
        catalogPropDto1.setName("自动化测试1_"+TestDataManager.getRandomNum(5));
        catalogPropDto1.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto1.setSubType("欧码");
        catalogPropDto1.setValue("170");

        CatalogPropDto catalogPropDto2 = new CatalogPropDto();
        catalogPropDto2.setName("自动化测试2_"+TestDataManager.getRandomNum(5));
        catalogPropDto2.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto2.setSubType("国码");
        catalogPropDto2.setValue("180");

        CatalogPropDto catalogPropDto3 = new CatalogPropDto();
        catalogPropDto3.setName("自动化测试3_"+TestDataManager.getRandomNum(5));
        catalogPropDto3.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto3.setSubType("美码");
        catalogPropDto3.setValue("190");

        CatalogPropDto catalogPropDto4 = new CatalogPropDto();
        catalogPropDto4.setName("自动化测试4_"+TestDataManager.getRandomNum(5));
        catalogPropDto4.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto4.setSubType("日码");
        catalogPropDto4.setValue("160");

        List<CatalogPropDto> propertyList1 = new ArrayList<>();
        List<CatalogPropDto> propertyList2 = new ArrayList<>();

        
        propertyList1.add(catalogPropDto1);
        propertyList1.add(catalogPropDto2);
        propertyList2.add(catalogPropDto3);
        propertyList2.add(catalogPropDto4);
        catalogDto.setPropertyList(propertyList1);
        //规格列表2
        CatalogDto CatalogDto = new CatalogDto();
        CatalogDto.setDirectPrice(900d);
        //CatalogDto.setDirectPrice(1d);
        CatalogDto.setStock(100);
        CatalogDto.setSku(sku2);
        CatalogDto.setWeight(1);
        CatalogDto.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_401.jpg");
        CatalogDto.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        CatalogDto.setAgentPriceList(agentPriceDtos);

        CatalogDto.setPropertyList(propertyList2);

        List<CatalogDto> catalogDtos = new ArrayList<>();
        catalogDtos.add(catalogDto);
        catalogDtos.add(CatalogDto);

        if(setAgentPrice){
            listagentTypeBean listagentTypeBean = GodmchManageCallService.InitlistgentTypeBean(sellerId);
            List<AgentTypeVo> agentTypeVos = GodmchManageCallService.listgentTypeCall(listagentTypeBean).getAgentTypes();
            catalogDtos.forEach(p->{
                List<AgentPriceDto> agentPriceDtos1 = new ArrayList<>();
                agentTypeVos.forEach(x->{
                    if (x.getAgentType()!=0){
                        AgentPriceDto agentPriceDto = new AgentPriceDto();
//                        agentPriceDto.setAgentTypeId(x.getAgentType());
                        agentPriceDto.setAgentTypeName(x.getTitle());
                        double price = Double.parseDouble(1+ TestDataManager.getRandomNum(2));
                        agentPriceDto.setAgentPrice(price);
                        agentPriceDtos1.add(agentPriceDto);
                    }
                });
                p.setAgentPriceList(agentPriceDtos1);
            });
        }
        addproductBean.setCatalogList(catalogDtos);
        addproductBean.setCatalogStatus(999);
        addproductBean.setCardInfo(0);
        addproductBean.setCategoryId(1002);
        addproductBean.setThirdCategoryId(1003);
        addproductBean.setBrandId(AddAgentProductCallService.BrandId);
        addproductBean.setRemark("测试商品");
        addproductBean.setCurrency("USD");
        addproductBean.setDescription("ceshishangping");
        addproductBean.setDescPicList(Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg"));
        //是否在买家端店铺首页中不可见 false 可见
        addproductBean.setInvisible(false);
        return addproductBean;

    }
    
    /**
     * 发布创建商品
     * @param agentProductBean
     * @return
     * @throws IOException
     */
    public static String AddProduct(AddProductBean agentProductBean) throws IOException {
        AddProductCall addProductCall = new AddProductCall();
        addProductCall.setData(agentProductBean);
        addProductCall.callService();
        return addProductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
    }
    
    /**
     * 修改价格
     * @param sellerId
     * @return
     * @throws InterruptedException 
     */
    public static void UpdatePrice(int sellerId,String productId,double price) throws Exception{
    	UpdatePriceBean updatepriceBean = new UpdatePriceBean();
    	UpdatePriceCall updatepriceCall = new UpdatePriceCall();
    	YmtCatalogsIWapper ymtCatalogsIWapper = new YmtCatalogsIWapper();
    	updatepriceBean.setUserId(sellerId);
		updatepriceBean.setProductId(productId);
		List<UpdatePriceDto> updateStockList = new ArrayList<>();
		String catalogId = ymtCatalogsIWapper.selectCatalogsByProductId(productId).get(0).getsCatalogId();
		String catalogId1 = ymtCatalogsIWapper.selectCatalogsByProductId(productId).get(1).getsCatalogId();
		UpdatePriceDto updatePriceDto = new UpdatePriceDto();
		updatePriceDto.setCatalogId(catalogId);
		updatePriceDto.setSalePrice(price);
		updateStockList.add(updatePriceDto);
    	updatepriceBean.setUpdatePriceList(updateStockList);
		updatepriceCall.setData(updatepriceBean);
		updatepriceCall.callService();
		Logger.verifyEquals("400",updatepriceCall.getString("code"),"验证code");
    }

    /**
     * 保存规格属性
     * @param saveCatalogPropertyBean
     * @throws IOException
     */
    public static void SaveCatalogProperty(SaveCatalogPropertyBean saveCatalogPropertyBean) throws IOException {
        SaveCatalogPropertyCall savecatalogpropertyCall = new SaveCatalogPropertyCall();
        savecatalogpropertyCall.setData(saveCatalogPropertyBean);
        savecatalogpropertyCall.callService();
    }
    
    /**
     * 初始化一品多码商品发布
     * @param sellerId 商户id
     * @param sellerName 商户名称
     * @param setAgentPrice 是否设置给下级代理
     */
    public static AddAgentProductBean initAddMultiCodeAgentProduct(int sellerId,String sellerName,boolean setAgentPrice) throws IOException {

        AddAgentProductBean addagentproductBean = new AddAgentProductBean();
        addagentproductBean.setUserId(sellerId);
        addagentproductBean.setUserName(sellerName);
        //发布类型 1-发布上架 2-保存为下架
        addagentproductBean.setSaleType(1);
        addagentproductBean.setSetAgentPrice(setAgentPrice);
        //标题
        addagentproductBean.setTitle("God"+TestDataManager.getRandomNum(6));
        addagentproductBean.setProductCode("货号" + TestDataManager.getRandomNum(10));
        
        addagentproductBean.setNationType(2);
        
        List<String> picList = new ArrayList<>();
        picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
        picList.add("http://pic1.ymatou.com/G01/M00/41/2B/rBBlD1yYU-SAJhweAADmTO2YrBw085_1_1_o.jpg");
        picList.add("http://pic1.ymatou.com/G01/M00/40/C9/rBBlD1yYTCmAZV4MAAFgY-30kgs700_1_1_o.jpg");
        //商品图片
        addagentproductBean.setPics(picList);
        //规格列表1
        CatalogDto catalogDto1 = new CatalogDto();
        //直销价
        catalogDto1.setDirectPrice(900d);
        //catalogDto.setDirectPrice(1d);
        //库存
        catalogDto1.setStock(10);
        catalogDto1.setWeight(3);
        catalogDto1.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
        String sku1 = TestDataManager.getRandomNum(9);
        String sku2 = TestDataManager.getRandomNum(9);
        //商户商品编码
        
        if (ShenqiUserSet.cdfMembergoodsOwnerId.intValue() == sellerId)
        	catalogDto1.setSku(sku1);
        else
        	catalogDto1.setSku(sku1);
        //规格名称
        catalogDto1.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));//已经没用
        List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
        catalogDto1.setAgentPriceList(agentPriceDtos);
        CatalogPropDto catalogPropDto1 = new CatalogPropDto();
        catalogPropDto1.setName("自动化测试1_"+TestDataManager.getRandomNum(5));
        catalogPropDto1.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto1.setSubType("欧码");
        catalogPropDto1.setValue("170");
        CatalogPropDto catalogPropDto2 = new CatalogPropDto();
        catalogPropDto2.setName("自动化测试2_"+TestDataManager.getRandomNum(5));
        catalogPropDto2.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto2.setSubType("国码");
        catalogPropDto2.setValue("180");

        CatalogPropDto catalogPropDto3 = new CatalogPropDto();
        catalogPropDto3.setName("自动化测试3_"+TestDataManager.getRandomNum(5));
        catalogPropDto3.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto3.setSubType("美码");
        catalogPropDto3.setValue("190");

        CatalogPropDto catalogPropDto4 = new CatalogPropDto();
        catalogPropDto4.setName("自动化测试4_"+TestDataManager.getRandomNum(5));
        catalogPropDto4.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
        catalogPropDto4.setSubType("日码");
        catalogPropDto4.setValue("160");

        List<CatalogPropDto> propertyList1 = new ArrayList<>();
        List<CatalogPropDto> propertyList2 = new ArrayList<>();

        propertyList1.add(catalogPropDto1);
        propertyList1.add(catalogPropDto2);
        propertyList2.add(catalogPropDto3);
        propertyList2.add(catalogPropDto4);
        catalogDto1.setPropertyList(propertyList1);
        
        //规格列表2
        CatalogDto catalogDto2 = new CatalogDto();
        catalogDto2.setDirectPrice(900d);
        //CatalogDto.setDirectPrice(1d);
        catalogDto2.setStock(10);
        
        if (ShenqiUserSet.cdfMembergoodsOwnerId.intValue() == sellerId)
        	catalogDto2.setSku(sku2);
        else
        	catalogDto2.setSku(sku2);
        
        catalogDto2.setWeight(1);
        catalogDto2.setPic("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_401.jpg");
        catalogDto2.setPropertyValue("God商品"+ TestDataManager.getRandomNum(10));
        catalogDto2.setAgentPriceList(agentPriceDtos);
        
        catalogDto2.setPropertyList(propertyList2);
        
        List<CatalogDto> catalogDtos = new ArrayList<>();
        catalogDtos.add(catalogDto1);
        catalogDtos.add(catalogDto2);
        
        catalogDtos.forEach(p -> {
        	
            List<CatalogSubCodeDto> subCodeList = new ArrayList<>();
            
            CatalogSubCodeDto catalogSubCodeDto1 = new CatalogSubCodeDto();
            
            catalogSubCodeDto1.setCode(TestDataManager.getRandomUUID().toString());
            catalogSubCodeDto1.setAttr("subCode_attr" + TestDataManager.randomStr(5));
            catalogSubCodeDto1.setEffectivePeriod("2030-04-09");
//            catalogSubCodeDto1.setEffectivePeriod(TestDataManager.getRandomNum(4) + "-04-09");
            catalogSubCodeDto1.setStock(5);
            
            CatalogSubCodeDto catalogSubCodeDto2 = new CatalogSubCodeDto();
            
            catalogSubCodeDto2.setCode(TestDataManager.getRandomUUID().toString());
            catalogSubCodeDto2.setAttr("subCode_attr"  + TestDataManager.randomStr(5));
            catalogSubCodeDto2.setEffectivePeriod("2029-04-09");
//            catalogSubCodeDto2.setEffectivePeriod(TestDataManager.getRandomNum(4) + "-04-09");
            catalogSubCodeDto2.setStock(5);
            
            subCodeList.add(catalogSubCodeDto1);
            subCodeList.add(catalogSubCodeDto2);
            
            p.setSubCodeList(subCodeList);
        });

        if(setAgentPrice){
            listagentTypeBean listagentTypeBean = GodmchManageCallService.InitlistgentTypeBean(sellerId);
            List<AgentTypeVo> agentTypeVos = GodmchManageCallService.listgentTypeCall(listagentTypeBean).getAgentTypes();
            catalogDtos.forEach(p->{
                List<AgentPriceDto> agentPriceDtos1 = new ArrayList<>();
                agentTypeVos.forEach(x->{
                    if (x.getAgentType()!=0){
                        AgentPriceDto agentPriceDto = new AgentPriceDto();
                        agentPriceDto.setAgentTypeId(x.getAgentType());
                        double price = Double.parseDouble(1+ TestDataManager.getRandomNum(2));
                        agentPriceDto.setAgentPrice(price);
                        agentPriceDtos1.add(agentPriceDto);
                    }
                });
                p.setAgentPriceList(agentPriceDtos1);
            });
        }
        addagentproductBean.setCatalogList(catalogDtos);
        addagentproductBean.setCatalogStatus(999);
        addagentproductBean.setCardInfo(0);
        addagentproductBean.setCategoryId(1002);
        addagentproductBean.setThirdCategoryId(1003);
        addagentproductBean.setBrandId(AddAgentProductCallService.BrandId);
        addagentproductBean.setRemark("测试商品");
        addagentproductBean.setCurrency("USD");
        addagentproductBean.setDescription("ceshishangping");
        addagentproductBean.setDescPicList(Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg"));
        //是否在买家端店铺首页中不可见 false 可见
        addagentproductBean.setInvisible(false);
        addagentproductBean.setExpressDelivery(true);
        addagentproductBean.setCollectionGoods(true);
        addagentproductBean.setMinOrderNum(0);
        return addagentproductBean;
    }
    
    public static void main(String[] args) throws IOException {
        int rootvip = 500002616;
        int vip1 = 500002617;
        int vip2 = 500002621;
        int vip3 = 500002622;
        int vip4 = 500002623;

        String name = "NickautoTest";
        for (int i=0;i<30;i++){
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(500019337,"NickautoTest",true);
            AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
        }

        /*YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
        List<AgentProductPo> agentProductPoList = ymtProductsIWapper.selectAgentProductByUserId(500002621,0);

        agentProductPoList.forEach(p->{
            try {
                AddAgentProductCallService.DeleteProduct(p.getProductId(),500002621);
            } catch (IOException e) {
                e.printStackTrace();
            }
        });*/



      /*  for (int i=0;i<30;i++){
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootvip,name,true);
            addAgentProductBean.setTitle("rootvip" + i);
            AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
        }
        YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
        List<AgentProductPo> agentProductPoList = ymtProductsIWapper.selectAgentProductByUserId(rootvip,0);
        System.out.println("agentProductPoList:"+agentProductPoList);
        agentProductPoList.forEach(p->{
            try {
                ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vip1,name,p.getProductId(),rootvip,true);
                importAgentProductBean.setTitle("vip1"+1);
                AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        ymtProductsIWapper.selectAgentProductByUserId(vip1,0).forEach(p->{
            try {
                ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vip2,name,p.getProductId(),vip1,true);
                importAgentProductBean.setTitle("vip2"+1);
                AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });

        ymtProductsIWapper.selectAgentProductByUserId(vip2,0).forEach(p->{
            try {
                ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vip3,name,p.getProductId(),vip2,true);
                importAgentProductBean.setTitle("vip3"+1);
                AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        ymtProductsIWapper.selectAgentProductByUserId(vip3,0).forEach(p->{
            try {
                ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vip4,name,p.getProductId(),vip3,false);
                importAgentProductBean.setTitle("vip4"+1);
                AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });*/

    }
    
}
